package com.project.music.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.music.bean.Collect;
import com.project.music.mapper.CollectMapper;
import com.project.music.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect> implements CollectService {

    @Autowired
    CollectMapper collectMapper;

    @Override
    public boolean existSong(int userId, int songId) {
        QueryWrapper<Collect> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                    .eq(Collect::getUserId, userId)
                    .eq(Collect::getSongId, songId);
        return collectMapper.selectCount(queryWrapper) > 0;
    }
}